package com.xxx.redirect;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/8/4 10:28
 * @Copyright 博为峰
 */
public class ServletDemo01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("ServletDemo01");
        resp.setHeader("s01","s01");
        resp.getWriter().write("ServletDemo01");
        /*
            重定向:
            1.设置响应头Location
            2.发送302状态码
         */
//        resp.setHeader("Location","/web02_war_exploded/s02");
//        resp.setStatus(302);
        resp.sendRedirect("/web02_war_exploded/s02");
//        resp.sendRedirect("https://www.baidu.com");
    }

}
